<?php

include_once 'core/Node.php';

class ButtonInterpreter{
	
	public function interpret(Node $node){
		$link = $node->getAttribute('@0');
		$text = $node->getAttribute('@1');
		$theme = $node->getAttribute('@2');
		$template = $node->getAttribute('template');
		$id = $node->getAttribute('id');
		
		
		$ret = '<a data-role="button"';
		if($link != '#'){
			$ret .= 'href="'.$link.'"';
		}
		if($id != ''){
			$ret .= ' id="'.$id.'"';
		}
		if(strpos($link, 'ttp://')){
			$ret .= ' rel="external"';
		}
		if($theme != ''){
			$ret .= ' data-theme="'.$theme.'"';
		}
		if($template != ''){
			$ret .= $this->$template($node);
		}
		$ret .='>'.$text.'</a>';
		
		return $ret;
	}
	
	function back(Node $node){
		return ' data-icon="back" data-direction="reverse"';
	}
	
	function gear(Node $node){
		return ' data-icon="gear"';
	}
	
	function check(Node $node){
		return ' data-icon="check"';
	}
	
	function delete(Node $node){
		return ' data-icon="delete"';
	}
}